<!-- 销售订单结算详情弹窗 -->
<template>
  <div>
  <a-form
    ref="form3"
    class="ele-form-detail"
    :model="saleOrderSettlementModalApp.saleOrderSettlement"
    :label-col="{md: {span: 2}, sm: {span: 4}, xs: {span: 6}}"
    :wrapper-col="{md: {span: 22}, sm: {span: 20}, xs: {span: 18}}">
    <a-descriptions :title="saleOrderSettlementModalApp.title" bordered>
      <a-descriptions-item label="创建人">
        {{ saleOrderSettlementModalApp.saleOrderSettlement.creatorName }}
      </a-descriptions-item>
      <a-descriptions-item label="销售订单">
        {{ saleOrderSettlementModalApp.saleOrderSettlement.saleOrderId }}
      </a-descriptions-item>
      <a-descriptions-item label="结算价格">
        {{ saleOrderSettlementModalApp.saleOrderSettlement.settlPrice }}
      </a-descriptions-item>
      <a-descriptions-item label="结算时间">
        {{ saleOrderSettlementModalApp.saleOrderSettlement.settlDate }}
      </a-descriptions-item>
      <a-descriptions-item label="流水号">
        {{ saleOrderSettlementModalApp.saleOrderSettlement.serialNum }}
      </a-descriptions-item>
      <a-descriptions-item label="备注">
        {{ saleOrderSettlementModalApp.saleOrderSettlement.remark }}
      </a-descriptions-item>
      <a-descriptions-item label="创建时间">
        {{ saleOrderSettlementModalApp.saleOrderSettlement.createDatetime }}
      </a-descriptions-item>
    </a-descriptions>
  </a-form>

  <vxe-table
    :data="orderInfoData">
    <vxe-column type="seq" width="60" title="序号"></vxe-column>
    <vxe-column field="name" title="名称"></vxe-column>
    <vxe-column field="menuPrice" title="单价"></vxe-column>
    <vxe-column field="amount" title="数量"></vxe-column>
    <vxe-column field="totalPrice" title="总价"></vxe-column>
  </vxe-table>
  </div>
</template>

<script>
import {defineComponent, reactive, onMounted, inject, ref} from "vue";
import {useRoute} from "vue-router"
import {SaleOrderSettlementService} from "@/views/restaurant/sale/saleOrderSettlement/saleOrderSettlementService";

export default defineComponent({
  setup() {
    const route = useRoute();
    let routeId = route.params.id;
    let saleOrderSettlementListApp = inject('saleOrderSettlementListApp', reactive({}));
    const saleOrderSettlementModalApp = reactive({id: null, saleOrderSettlement: {}, display: false});

    onMounted(() => {
      saleOrderSettlementModalApp.saleOrderSettlement = {};
      if (routeId) {
        saleOrderSettlementModalApp.id = routeId;
      } else if (saleOrderSettlementListApp.viewModalShowing) {
        saleOrderSettlementModalApp.id = saleOrderSettlementListApp.currentId;
        saleOrderSettlementModalApp.display = true;
      }
      if (saleOrderSettlementModalApp.id) {
        getInfo(saleOrderSettlementModalApp.id);
      }
    })

    const getInfo = (id) => {
      SaleOrderSettlementService.findSaleOrderSettlement(id).then((res) => {
        saleOrderSettlementModalApp.saleOrderSettlement = res.data;
        SaleOrderSettlementService.getMenuSaleRecordsByOrderId(saleOrderSettlementModalApp.saleOrderSettlement.saleOrderId).then((r)=>{
          orderInfoData.value=r.data;
          orderInfoData.value.forEach(item=>{
            item.totalPrice=item.menuPrice*item.amount;
          })
        })
      })
    }
    const orderInfoData = ref([]);

    return {
      saleOrderSettlementModalApp,
      routeId,
      getInfo,
      orderInfoData
    }
  }
})
</script>

<style scoped>
</style>

